<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var sum = 0;
      for (var i = 1; i <= 100; i++) {
        sum += i;
      }
      console.log(sum);

      // 求1---100之间 所有 偶数的和
      var res = 0;
      for (var i = 1; i <= 100; i++) {
        if (i % 2 === 0) {
          res += i;
        }
      }
      console.log(res);

      var res1 = 0;
      for (var i = 2; i <= 100; i += 2) {
        res1 += i;
      }
      console.log(res1);
    </script>
  </body>
</html>
